package com.example.postman.restful.mapper;

import com.example.postman.exception.ValidattionException;
import com.example.postman.restful.entity.PostMan;
import com.example.postman.restful.entity.User;
import org.springframework.stereotype.Repository;

/**
 * 类
 * 创建时间：2022/3/14 17:34
 *
 * @author gejin
 */
@Repository
public class PostManMapper {
    PostMan postMan = new PostMan();

    public int add(PostMan postMan) {
        return 0;
    }

    public PostMan getPostManById(String postId) {
        postMan.setPostId("0002");
        postMan.setPostName("newPostManName");
        return postMan;
    }

    public int updatePostMan(PostMan postMan) {
        return 0;
    }

    public int deletePostManById(String postId) {
        return 0;
    }

    public String getAreaCode(String phone) {
        return "16634569986";
    }

    public String getOprateCode(String phone) {
        return "200";
    }

    public String findRep(String areaCode, String oprateCode) {
        return "ok, it is running";
    }

    public User save(String areaCode, String oprateCode, String rep) throws ValidattionException {
        User user;
        try {
            user = new User(areaCode, oprateCode, rep);
        } catch (NullPointerException e) {
            throw new ValidattionException("有不合法的参数！");
        }
        return user;
    }

    /*
        int add(PostMan postMan);

        PostMan getPostManById(String postId);

        int updatePostMan(PostMan postMan);

        int deletePostManById(String postId);

     */


}
